package cn.gson.crm.control.callback;

import java.util.List;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mysql.jdbc.StringUtils;

import cn.gson.crm.control.base.BaseServlet;
import cn.gson.crm.model.dao.CallbackDao;
import cn.gson.crm.model.po.CallbackPo;

@WebServlet("/callback/manager")

public class CallbackManagerServlet extends BaseServlet{
	private CallbackDao callbackDao  = new CallbackDao();
		
	private static final long serialVersionUID = 1L;
	
	@Override
	protected void get(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String nowpage = request.getParameter("nowpage");
		String stuname = request.getParameter("stuname");
		String stucompany = request.getParameter("stucompany");
		int stuid = 0 ;
		if(!StringUtils.isNullOrEmpty(stuname)){
			stuid = callbackDao.getStuId(stuname);
		}
		if(nowpage == null){
			nowpage = "1";
			}
		int page = callbackDao.getCallbackPageSum();
		List<CallbackPo> callbackPoList = callbackDao.getAllCallbackList(Integer.parseInt(nowpage),stuid,stucompany);
		request.setAttribute("callbackPoList", callbackPoList);
		request.getSession().setAttribute("pageSum", page);
		request.getSession().setAttribute("nowpage", nowpage);
		forward("callback/callback_manager.jsp");
	}

	
	@Override
	protected void post(HttpServletRequest request, HttpServletResponse response) throws Exception {
			get(request, response);
	}
}
